package remoteControlSpy;

import java.io.IOException;

/**
 * this class (part of the MVC structure) calls the model function that
 * will start the OS listener and getting updates from server
 */
public class StartExecuter 
{
	ServiceManager sm = ServiceManager.getInstance();
	/**
	 * A handle to the unique ServiceMangaer instance.
	 */
	static private StartExecuter instance = null;
	//for singleton
	private static Object someObject = new Object();

	// the private constructor of this class
	private StartExecuter(){}	

	/**
	 * this function create an instance of this class or return it if it already existed
	 * @return - the only instance of this class
	 */
	static public StartExecuter getInstance() 
	{
		if(null == instance) 
		{
			//to insure that the time slice doesn't cause to creation of 2 instances
			synchronized (someObject) 
			{
				if (null == instance)
					instance = new StartExecuter();
			}
		}
	    return instance;
	}
	
	/**
	 * this function calls the model function that will start the service
	 * @throws IOException
	 */
	public void execute() throws IOException
	{
		sm.startTheService();
	}
}
